home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / exec / funsub.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.1 KB  |  54 lines

  1. /*
  2. \funcref{fun\_sub}{void fun\_sub ()}
  3.     {}
  4.     {}
  5.     {pop(), copylist(), delfromlist(), discard()}
  6.     {}
  7.     {funsub.c}
  8.     {
  9.  
  10.         Function {\em fun\_sub()} processes opcode {\em op\_sub}. Two variables
  11.         are popped and subtracted. Depending on their type, two integer values
  12.         are subtracted or a difference between two lists is computed.
  13.  
  14.         The result of the subtraction is stored in a temporary variable, which
  15.         is then pushed.
  16.  
  17.         The two popped variables are discarded after use.
  18.     }
  19. */
  20.  
  21. #include "icm-exec.h"
  22.  
  23. void fun_sub ()
  24. {
  25.     VAR_
  26.         tmp,
  27.         lval,
  28.         rval;
  29.     register unsigned
  30.         i;
  31.     register LIST_
  32.         *rlist;
  33.  
  34.     rval = pop ();
  35.     lval = pop ();
  36.  
  37.     if (lval.type & e_int)
  38.     {
  39.         tmp.type = e_int;
  40.         tmp.vu.intval = lval.vu.intval - rval.vu.intval;
  41.     }
  42.     else
  43.     {
  44.         tmp = copylist (lval);
  45.         if ( (rlist = &(rval.vu.i->ls.list)) )
  46.             for (i = 0; i < rlist->size; i++)
  47.                 tmp = delfromlist (tmp, rlist->element [i]);
  48.     }
  49.  
  50.     push (tmp);
  51.     discard (lval);
  52.     discard (rval);
  53. }
  54.